#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>
#include <string.h>

//模拟实现strncmp
int my_strncmp(const char* string1, const char* string2, size_t n)
{
	assert(string1 && string2);
	//指定次数n
	while (n--)
	{
		while (*string1 == *string2)
		{
			if (string1 == '\0')
			{
				return 0;
			}
			string1++;
			string2++;
		}
		if (*string1 > *string2)
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}
	return 0;

}
int main()
{
	char arr1[] = "abcdefg";
	char arr2[] = "abckghjk";
	int ret = my_strncmp(arr1, arr2, 4);
	return 0;
}